package com.xiaoshuidi.cloud.framework.filings.core.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 合同状态
 * @Author Feng
 * @date 2023/5/5
 */
@Getter
@AllArgsConstructor
public enum ContractStatusEnum {

    CONTRACT_SIGNING(1,"合同签订"),
    CONTRACT_MODIFICATION(2, "合同变更"),
    CONTRACT_SSALC(3, "合同退租"),
    CONTRACT_EXPIRES(4, "合同失效"),
    CONTRACT_EXPIRES_STAGE(5, "合同到期");

    private int code;
    private String name;

    public static Integer getCodeByName(String name) {
        if (StrUtil.isEmpty(name)) {
            return null;
        }
        Optional<ContractStatusEnum> find = Arrays.stream(ContractStatusEnum.values()).filter(s -> s.getName().equals(name)).findFirst();
        if (find.isPresent()) {
            return find.get().getCode();
        }
        return null;
    }
}